/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.belfalas.simy86.operadores;

import org.belfalas.simy86.Registradores;
import org.belfalas.simy86.Y86;

/**
 *
 * @author belfalas
 */
public class RET extends Operador{

    public void fetch(org.belfalas.simy86.Operador_Stat stat) {
        stat.valP = stat.pc+1;
        stat.rB = Registradores.ESP;
        stat.rB.incUsage();
    }

    public void decode(org.belfalas.simy86.Operador_Stat stat) {
        //stat.valA = stat.rB.reg;
        stat.valB = stat.rB.reg;
    }

    public void execute(org.belfalas.simy86.Operador_Stat stat) {
        stat.valE = stat.valB+4;
    }

    public void memory(org.belfalas.simy86.Operador_Stat stat) {
        stat.valM = Y86.memoria.readSignedWord(stat.valB);
    }

    public void writeback(org.belfalas.simy86.Operador_Stat stat) {
        stat.rB.reg = stat.valE;
        stat.rB.decUsage();
        //PC.position = (int) stat.valM;
    }

    
}
